#include <iostream>
#include <string>

#include <unistd.h>
#include <pthread.h>

class Request
{
public:
    Request(int start, int end, const std::string& threadname)
        : _start(start)
        , _end(end)
        , _threadname(threadname)
    {}

public:
    int _start;
    int _end;
    std::string _threadname;
};

class Response
{
public:
    Response(int result, int exitcode)
        : _result(result)
        , _exitcode(exitcode)
    {}

public:
    int _result;
    int _exitcode;
};

void* sumCount(void* args)
{
    Request* rq = static_cast<Request*>(args);
    Response* rsp = new Response(0, 0);
    for (int i = rq->_start; i <= rq->_end; ++i)
        rsp->_result += i;
    return rsp;
}

int main()
{
    Request* rq = new Request(1, 100, "Thread 1");
    pthread_t tid;
    pthread_create(&tid, nullptr, sumCount, rq);

    void* retval;
    pthread_join(tid, &retval);
    Response* rsp = static_cast<Response*>(retval);
    std::cout << "rsp->_result: " << rsp->_result << " exitcode: " << rsp->_exitcode << std::endl;
    delete rsp;

    return 0;
}